package basic.lessons;

import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;

public class ChessBoardApplet extends Applet{
	
	
	public void paint(Graphics g) {

        // Draw a set of nested black rectangles on a red background.
        // Each nested rectangle is separated by 15 pixels on
        // all sides from the rectangle that encloses it.
        
     int insetW=0;    // inset by width 
     int insetH=0;    // inset by height     
     
//     g.setColor(Color.red);
//     g.fillRect(insetW,insetH,20,20);  // Fill the square applet with red.
//     
//     g.setColor(Color.black);
//     g.fillRect(insetW,insetH,20,20);  // Fill the square applet with black.

		for (int i = 1; i <= 8; i++) {
			for (int j = 1; j <= 8; j++) {
				if ((j + i) % 2 == 0) {
					g.setColor(Color.black);
					g.fillRect(insetW, insetH, 20, 20);
					insetH += 20;
				} else {
					g.setColor(Color.red);
					g.fillRect(insetW, insetH, 20, 20);
					insetH += 20;
				}
			}
			insetW += 20;
			insetH = 0;
		}

	}
     

}
